<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="__PUBLIC__/admin/sncss/css/style.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/sncss/css/combo.select.css" rel="stylesheet" type="text/css" />

</head>

<body>

	<div class="place">
	<span>位置：</span>
	<ul class="placeul">
	<li><a>首页</a></li>
	<li><a>自媒体管理</a></li>
	<li><a>修改自媒体</a></li>
	</ul>
	</div>

	<div class="formbody">

	<div class="formtitle"><span>自媒体信息</span></div>
		<form id="form1" name="form1" method="post" enctype="multipart/form-data" action="{:U('/Home/Media/edit_media')}" onsubmit="return form1_submit();">
		<input name="mmid"  type="hidden" class="dfinput" value="{$mediadata['mmid']}" />
		<input name="audio_op_old"  type="hidden" class="dfinput" value="{$mediadata['audio_op']}" />
		<input name="audio_bgm_old"  type="hidden" class="dfinput" value="{$mediadata['audio_bgm']}" />
		<input name="media_pic_old"  type="hidden" class="dfinput" value="{$mediadata['media_pic']}" />
	<ul class="forminfo">

	<li><label>名称</label><input name="media_name" id="media_name" type="text" class="dfinput" value="{$mediadata['media_name']}" /><i></i></li>
	<li><label>手机号</label><input name="media_tel" id="media_tel" type="text" class="dfinput" value="{$mediadata['media_tel']}" /><i></i></li>
	<li><label>邮箱</label><input name="email" id="email" type="text" class="dfinput" value="{$mediadata['email']}" /><i></i></li>
	<li><label style="float: left;">类型</label>
		<div style="width: 690px; float: left;">
		<?php foreach ($labeldata as $key => $value) { ?>
				<label><input name="articles[]" type="checkbox" value="<?php echo $value['label_id'];?>" <?php foreach($mediadata['articles'] as $k => $v){if($value['label_id']==$v){echo "checked='checked'";}}?>/><?php echo $value['label_name'];?></label>
		<?php }?>
		</div>
	</li>

	<li>
	<div style="width: 86px; float: left;">
	<label>时段</label>
	</div>
	<div>
		<select class="timebody1 newselect" name="timepoint">
			<?php for ($i=0; $i < 24; $i++) { ?>
				<option value ="<?php echo $i;?>" <?php if($mediadata['timepoint']==$i){echo "selected='selected'";}?>><?php echo $i;?>时</option>
			<?php }?>
		</select>
	</div>
	</li>
	<li><label>简介</label><textarea name="media_message" id="media_message" type="text" class="textinput">{$mediadata['media_message']}</textarea><i></i></li>
	<li><label>已合作自媒体</label>
	<label><input name="subscript" type="radio" value="1" <?php if($mediadata['subscript']==1){echo "checked='checked'";}?> />是</label>
	<label><input name="subscript" type="radio" value="0" <?php if($mediadata['subscript']==0){echo "checked='checked'";}?> />否</label>
	</li>
	<li><label>是否热门</label>
	<label><input name="ishot" type="radio" value="1" <?php if($mediadata['ishot']==1){echo "checked='checked'";}?> />是</label>
	<label><input name="ishot" type="radio" value="0" <?php if($mediadata['ishot']==0){echo "checked='checked'";}?> />否</label>
	</li>
	<li>
		<div style="width: 86px;line-height: 34px;display: block;float: left;">片头曲</div>
		<audio src="{$mediadata['audio_op']}" id='ad-op' controls="controls">您的浏览器不支持 audio 标签。</audio>
			<div id="container_op" style="float: left;">
				<a class="btn" id="pickfiles_op" href="#" style="display: block; text-align: center;line-height: 36px;" ><span id="updata_more_audio_finish_op">选择文件</span></a>
				<input id="audio_op" type="hidden" value="" name="audio_op" />
			</div>
		<div style="clear: both;"></div>
	</li>
	<li>
		<div style="width: 86px;line-height: 34px;display: block;float: left;">背景音</div>
		<audio src="{$mediadata['audio_bgm']}" id='ad-bgm' controls="controls">您的浏览器不支持 audio 标签。</audio>
		<div id="container_bgm" style="float: left;">
			<a class="btn" id="pickfiles_bgm" href="#" style="display: block; text-align: center;line-height: 36px;" ><span id="updata_more_audio_finish_bgm">选择文件</span></a>
			<input id="audio_bgm" type="hidden" value="" name="audio_bgm" />
		</div>
		<div style="clear: both;"></div>
	</li>
	<li>
		<div style="width: 86px;line-height: 34px;display: block;float: left;">头像</div>
		<div id="container_pic" style="float: left;">
			<a class="btn" id="pickfiles_pic" href="#" style="display: block; text-align: center;line-height: 36px;" ><span id="updata_more_audio_finish_pic">选择文件</span></a>
			<input id="media_pic" type="hidden" value="" name="media_pic" />
		</div>
		<img src="{$mediadata['media_pic']}" onerror="this.src=''" width='200' id='ad-img'/>
		<div style="clear: both;"></div>
	</li>
	<li><br><br><label>&nbsp;</label><input name="" type="submit" class="btn" value="确认"/></li>
	</ul>
		</form>

	</div>


</body>
<script src="__PUBLIC__/js/jquery1.8.3.js"></script>
<script src="__PUBLIC__/layer/layer.js"></script>

<script type="text/javascript">


function form1_submit(){
	var reg = /^1[3|4|5|6|7|8][0-9]{9}$/; //验证手机号规则
	var isEmail = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/; //验证邮箱规则
	var media_name= $('#media_name').val();
	if(media_name.length == 0){
		layer.tips('请填写名称', '#media_name');return false;
	}
	var media_tel= $('#media_tel').val();
	if(!reg.test(media_tel)){
		layer.tips('手机号格式不正确', '#media_tel');return false;
	}
	var email= $('#email').val();
	if(!isEmail.test(email)){
		layer.tips('邮箱格式不正确', '#email');return false;
	}

	// alert("submit");return false;

}

</script>
<script type="text/javascript" src='__PUBLIC__/admin/Js/plupload.full.min.js'></script>
<!-- qiniu.js依赖于Plupload，所以Plupload要在qiniu.js之前引用 -->
<script type="text/javascript" src="__PUBLIC__/admin/Js/qiniu.js"></script>
<script type="text/javascript">
	//===========================================================================================================================================
	Qiniu.uploader({
			runtimes: 'html5,flash,html4',
			browse_button: 'pickfiles_op',
			// HTML中重要的div的ID
			container: 'container_op',
			drop_element: 'container_op',
			max_file_size: '100mb',
			dragdrop: true,
			chunk_size: '100mb',
			uptoken_url:'http://test.heardtech.com/home/Common/uptoken2',
			domain: 'http://audio.qiniudn.com',
			get_new_uptoken: false,
			auto_start:true,
			log_level: 5,
			unique_names: false,
			save_key: false,
			init: {
				'FilesAdded': function(up, file) {
				},
				'BeforeUpload': function(up, file) {
				},
				'UploadProgress': function(up, file) {
					console.log(file.name, file.percent);
          $('#updata_more_audio_finish_op').text('正在上传（' + file.percent + '%）');
				},
				'UploadComplete': function(up,file) {
						// console.log("我是七牛",this);
				},
				'FileUploaded': function(up, file, info) {
						// console.log('文件上传完成后！');
          	$('#updata_more_audio_finish_op').text('上传成功');
						var obj=$.parseJSON(info.response);
						var hash=obj.hash;
						var key=obj.key;
						var persistentId=obj.persistentId;
						$('#audio_op').val(key);
						$("#ad-op").attr('src',"http://audio.heardtech.com/"+key);

				},
				'Error': function(up, err, errTip) {
          	$('#updata_more_audio_finish_op').text('上传失败');
				},
				'Key': function(up, file) {
						var key = "";
						key=randomWord(true,1,10)+file.name;
						return key
				}
			}
	});
	Qiniu.uploader({
			runtimes: 'html5,flash,html4',
			browse_button: 'pickfiles_bgm',
			// HTML中重要的div的ID
			container: 'container_bgm',
			drop_element: 'container_bgm',
			max_file_size: '100mb',
			dragdrop: true,
			chunk_size: '100mb',
			uptoken_url:'http://test.heardtech.com/home/Common/uptoken2',
			domain: 'http://audio.qiniudn.com',
			get_new_uptoken: false,
			auto_start:true,
			log_level: 5,
			unique_names: false,
			save_key: false,
			init: {
				'FilesAdded': function(up, file) {
				},
				'BeforeUpload': function(up, file) {
				},
				'UploadProgress': function(up, file) {
					console.log(file.name, file.percent);
          $('#updata_more_audio_finish_bgm').text('正在上传（' + file.percent + '%）');
				},
				'UploadComplete': function(up,file) {
						// console.log("我是七牛",this);
				},
				'FileUploaded': function(up, file, info) {
						// console.log('文件上传完成后！');
          	$('#updata_more_audio_finish_bgm').text('上传成功');
						var obj=$.parseJSON(info.response);
						var hash=obj.hash;
						var key=obj.key;
						var persistentId=obj.persistentId;
						$('#audio_bgm').val(key);
						$("#ad-bgm").attr('src',"http://audio.heardtech.com/"+key);

				},
				'Error': function(up, err, errTip) {
          	$('#updata_more_audio_finish_bgm').text('上传失败');
				},
				'Key': function(up, file) {
						var key = "";
						key=randomWord(true,1,10)+file.name;
						return key
				}
			}
	});
	Qiniu.uploader({
			runtimes: 'html5,flash,html4',
			browse_button: 'pickfiles_pic',
			// HTML中重要的div的ID
			container: 'container_pic',
			drop_element: 'container_pic',
			max_file_size: '100mb',
			dragdrop: true,
			chunk_size: '10mb',
			uptoken_url:'http://test.heardtech.com/home/Common/uptoken2',
			domain: 'http://audio.qiniudn.com',
			get_new_uptoken: false,
			auto_start:true,
			log_level: 5,
			unique_names: false,
			save_key: false,
			init: {
				'FilesAdded': function(up, file) {
				},
				'BeforeUpload': function(up, file) {
				},
				'UploadProgress': function(up, file) {
					console.log(file.name, file.percent);
          $('#updata_more_audio_finish_pic').text('正在上传（' + file.percent + '%）');
				},
				'UploadComplete': function(up,file) {
						// console.log("我是七牛",this);
				},
				'FileUploaded': function(up, file, info) {
						// console.log('文件上传完成后！');
          	$('#updata_more_audio_finish_pic').text('上传成功');
						var obj=$.parseJSON(info.response);
						var hash=obj.hash;
						var key=obj.key;
						var persistentId=obj.persistentId;
						console.log(key);
						$('#media_pic').val(key);
						$("#ad-img").attr('src',"http://audio.heardtech.com/"+key);
				},
				'Error': function(up, err, errTip) {
          	$('#updata_more_audio_finish_pic').text('上传失败');
				},
				'Key': function(up, file) {
						var key = "";
						key=randomWord(true,1,10)+file.name;
						return key
				}
			}
	});
	//随机生成随机数
	function randomWord(randomFlag, min, max){
			var str = "",
					range = min,
					arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
			// 随机产生
			if(randomFlag){
					range = Math.round(Math.random() * (max-min)) + min;
			}
			for(var i=0; i<range; i++){
					pos = Math.round(Math.random() * (arr.length-1));
					str += arr[pos];
			}
			return str;
	}
//=====================================================================================================================================
</script>
</html>
